package ${package.Rest};

import com.dtyunxi.rest.RestResponse;
import ${package.IApi}.I${entity}Api;
import ${package.Requestdto}.${entity}ReqDto;
import ${package.Responsedto}.${entity}RespDto;
import ${package.IQueryapi}.I${entity}QueryApi;
import com.github.pagehelper.PageInfo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

/**
* ${table.comment}Rest类
*
* @author ${author}
* @since ${date}
*/
@RestController
@RequestMapping("/v1/${entity?uncap_first}")
public class ${entity}Rest implements I${entity}Api,I${entity}QueryApi {

    @Resource
    private I${entity}Api ${entity?uncap_first}Api;
    @Resource
    private I${entity}QueryApi ${entity?uncap_first}QueryApi;

    @Override
    public RestResponse<Long> add${entity}(@RequestBody ${entity}ReqDto addReqDto) {
        return ${entity?uncap_first}Api.add${entity}(addReqDto);
    }

    @Override
    public RestResponse<Void> modify${entity}(@RequestBody ${entity}ReqDto modifyReqDto) {
        return ${entity?uncap_first}Api.modify${entity}(modifyReqDto);
    }

    @Override
    public RestResponse<Void> remove${entity}(@PathVariable("ids") String ids,
                                          @RequestParam("instanceId") Long instanceId) {
        return ${entity?uncap_first}Api.remove${entity}(ids, instanceId);
    }

    @Override
    public RestResponse<${entity}RespDto> queryById(@PathVariable("id") Long id) {
        return ${entity?uncap_first}QueryApi.queryById(id);
    }

    @Override
    public RestResponse<PageInfo<${entity}RespDto>> queryByPage(@RequestParam("filter") String filter,
                                                           @RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                                           @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize) {
        return ${entity?uncap_first}QueryApi.queryByPage(filter, pageNum, pageSize);
    }


}
